Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
CastError: la conversión a ObjectId falló para el valor "XXXXXXXXXX" (tipo cadena) en la ruta "_id" para el modelo "Usuario" para pasaporte-linkedin-oauth2

Obtener el error anterior al intentar autenticar a un nuevo usuario mediante oAuth 2.0 de LinkedIn. Parece que me están pasando un ObjectId de 10 dígitos en lugar de una identificación de 12 o 24 caracteres...

 passport.use(new LinkedInStrategy({ clientID: process.env.LI_ID, clientSecret: process.env.LI_SECRET, callbackURL: "http://localhost:3000/auth/linkedin/think-it", scope: ['r_emailaddress', 'r_liteprofile'], state: true }, function(accessToken, refreshToken, profile, done) { // asynchronous verification, for effect... process.nextTick(function () { // To keep the example simple, the user's LinkedIn profile is returned to // represent the logged-in user. In a typical application, you would want // to associate the LinkedIn account with a user record in your database, // and return that user instead. return done(null, profile); }); }));

Me estoy quedando colgado en:

 passport.deserializeUser(function(id, done) { User.findById(id, function(err, user) { done(err, user); }); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Resuelto. No estaba devolviendo a un usuario de mi base de datos. Del código de arriba:

 ...function(accessToken, refreshToken, profile, done) { // asynchronous verification, for effect... process.nextTick(function () { //code below was not present when I was getting the error: User.findOrCreate({ linkedInId: profile.id}, function(err, user) { if (err) { return done(err); } done(null, user); }); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!